package com.example.demo.demos.controller;

import org.apache.ibatis.annotations.Result;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
//http://localhost:8082/redis/save?key=name&value=zhangsan
@RestController
@RequestMapping("redis")
public class Redis {

    private final RedisTemplate redisTemplate;

    public Redis(RedisTemplate redisTemplate) {
        this.redisTemplate = redisTemplate;
    }

    @GetMapping("save")
    public String save(String key, String value){
        System.out.println(key);
        System.out.println(value);
        redisTemplate.opsForValue().set(key, value);

        return "1";
    }
}
